package com.tjbklx1.pattern.composite.demo3;

import java.util.ArrayList;

/**
 * 树枝构件
 * @author tjbklx1
 * @date 2018-10-11
 */
public class Composite extends Component {
	// 构件容器
	private ArrayList<Component> componentArrayList = new ArrayList<Component>();

	// 增加一个叶子构件或树枝构件
	public void add(Component component) {
		this.componentArrayList.add(component);
	}

	// 删除一个叶子构件或树枝构件
	public void remove(Component component) {
		this.componentArrayList.remove(component);
	}

	// 获得分支下的所有叶子构件和树枝构件
	public ArrayList<Component> getChildren() {
		return this.componentArrayList;
	}
	
	@Override
	public void doSomething() {
		System.out.println("Composite doSomething...");
	}
}